Skip to content

bugfix: skip lint when KB has no indexed documents#21

Merged
KylinMountain merged 2 commits intomainfrom
fix/lint-empty-kb
Apr 12, 2026
Merged

bugfix: skip lint when KB has no indexed documents#21
KylinMountain merged 2 commits intomainfrom
fix/lint-empty-kb

Conversation

@KylinMountain
Copy link
Copy Markdown
Collaborator

Summary

  • Early-exit openkb lint when the hash registry is empty (no documents added yet)
  • Previously, an empty KB would: run structural lint (all zero issues), call the LLM for knowledge lint (wasting an API call), write an empty report to wiki/reports/, and log the operation
  • Now prints "Nothing to lint — no documents indexed yet." and returns immediately

Test plan

  • 4 new tests in tests/test_lint_cli.py (201 total passing)
  • openkb init && openkb lint — should show early-exit message, no report written
  • openkb add <file> && openkb lint — should run normally

When the hash registry is empty (no documents added yet), lint would
still run structural checks (all zero), call the LLM for knowledge
lint (wasting an API call), write an empty report file, and log the
operation. Now it exits early with a clear message instead.
@KylinMountain KylinMountain changed the title Skip lint when KB has no indexed documents bugfix: skip lint when KB has no indexed documents Apr 12, 2026
@KylinMountain
Copy link
Copy Markdown
Collaborator Author

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

1 similar comment
@KylinMountain
Copy link
Copy Markdown
Collaborator Author

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

- Hoist the hashes check above _setup_llm_key/config/model so that
  an empty KB exits immediately without triggering API key warnings
- Add missing assert result.exit_code == 0 in test_lint_runs_when_docs_exist
@KylinMountain KylinMountain merged commit 0b19f9c into main Apr 12, 2026
@KylinMountain KylinMountain deleted the fix/lint-empty-kb branch April 12, 2026 01:39
@rejojer rejojer mentioned this pull request Apr 13, 2026
1 task
Mizelan pushed a commit to Mizelan/OpenKB that referenced this pull request Apr 18, 2026
* Skip lint when knowledge base has no indexed documents
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant